import request from '@/axios'
import type { CurdData } from './types'

export const getFieldEnumApi = (params: any): Promise<IResponse> => {
  return request.get({ url: '/admin/role/fieldEnum', params })
}

export const getListApi = (params: any) => {
  return request.get({ url: '/admin/role', params })
}
export const getRoleListApi = (params: any) => {
  return request.get({ url: '/admin/role', params })
}

//更新状态
export const changeStatusApi = (data) => {
  return request.put({ url: '/admin/role/status', data })
}
//新增角色
export const createRoleApi = (data): Promise<IResponse> => {
  return request.post({ url: `/admin/role`, data })
}
//更新角色
export const editRoleApi = (data): Promise<IResponse> => {
  return request.put({ url: `/admin/role`, data })
}
//删除角色
export const delRoleApi = (data): Promise<IResponse> => {
  return request.delete({ url: `/admin/role`, data })
}
//角色详情
export const getRoleShowApi = (params?: any) => {
  return request.get({ url: '/admin/role/detail', params })
}
export const saveApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/role', data })
  } else {
    return request.post({ url: '/admin/role', data })
  }
}
